package cn.shafish.nettyclient.messagehandler.heartbeat;

import cn.shafish.nettyclient.message.heartbeat.HeartbeatResponse;
import cn.shafish.nettycommon.dispatcher.MessageHandler;
import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 接收到消息时进行处理，Netty自带心跳功能检测功能，
 * 在channelPipeline中使用自定义ChannelHandler操作,其userEventTriggered方法可以进行事件监听
 */
@Component
public class HeartbeatResponseHandler implements MessageHandler<HeartbeatResponse> {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void execute(Channel channel, HeartbeatResponse message) {
        logger.info("[execute][收到连接({}) 的心跳响应]", channel.id());
    }

    @Override
    public String getType() {
        return HeartbeatResponse.TYPE;
    }
}
